<?php
if(!defined('ADMIN')){
	exit('Access Denied');
}
if($_POST['sub']!=''){
    $id=empty($_POST['id'])?0:(int)$_POST['id'];
	unset($_POST['id']);
	unset($_POST['sub']);
      if(empty($_POST["title"])){
          jumpajax('300','名称一项不能为空!','');
      }
      if(empty($_POST["money"])){
          jumpajax('300','金额一项不能为空!','');
      }
      if(empty($_POST["spendmoney"])){
          jumpajax('300','消费金额一项不能为空!','');
      }
    $status=intval($_REQUEST["status"]);
    $p=0;
	$data=array(
    'displayorder'=>trim($_POST["displayorder"]),
    'starttime'=>strtotime($_POST["datelimit1-start"]),
    'endtime'=>strtotime($_POST["datelimit1-end"]),
    'title'=>trim($_POST["title"]),
    'money'=>trim($_POST["money"]),
    'pretotal'=>trim($_POST["pretotal"]),
    'total'=>trim($_POST["total"]),
    'thumb'=>trim($_POST["imgs0_fileName"]),
    'content'=>trim($_POST["content"]),
            'status'=>$status,
    'spendmoney'=>trim($_POST["spendmoney"]),
    );
   
 	if($id==0){
        $id=$ezhand->insert("card_coupon",$data);
		jumpajax('200','优惠券保存成功','page481','closeCurrent');
	}else{

        $ezhand->update("card_coupon",$data,'id="'.$id.'"');          
		jumpajax('200','优惠券修改成功','page481','closeCurrent');
	}
}else{
	$id=empty($_GET['id'])?0:(int)$_GET['id'];
    if($id==0){
	    $row=array();
        $item["status"]=0;
	}else{
	   
	    $item=$ezhand->select("card_coupon",'*','id="'.$id.'"');
	}
}
?>